﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MyCollections
{
    public partial class dbviewer : Form
    {
        private string type;
        public dbviewer()
        {
            InitializeComponent();
        }

        public dbviewer(string type)
        {
            this.type = type;
            InitializeComponent();
            Load_db();
        }

        private void Load_db()
        {
            string pathxml = "";
            switch(this.type)
            {
                // FIXME
                case "movies":
                    pathxml = "XMLData\\db_movies.xml";
                    break;
                case "music": break;
                case "games": break;
                case "software": break;
                case "ebooks": break;
            }

            // DATAGRID

            DataSet objDataSet = new DataSet();
            objDataSet.ReadXml(pathxml, XmlReadMode.Auto);
            dg_result.SetDataBinding(objDataSet, "Filmes");
            dg_result.TableStyles.Add(new DataGridTableStyle());

            foreach (DataGridColumnStyle vColumnStyle in dg_result.TableStyles[0].GridColumnStyles)
            {

                vColumnStyle.Width = 100;

                if (vColumnStyle.HeaderText.ToLower() == "mycolumn")
                {

                    //vColumnStyle.HeaderText = "";
                    //vColumnStyle.MappingName = "";
                    //vColumnStyle.Alignment =  System.Windows.Forms.HorizontalAlignment.Center ;
                    vColumnStyle.Width = 60;    

                }
            }

            DataGridViewColumn col = new DataGridViewColumn();
            col.Name = "col1";
            col.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;

            DataGridViewColumn co2 = new DataGridViewColumn();
            co2.Name = "col2";
            col.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;

            DataGridViewColumn co3 = new DataGridViewColumn();
            co3.Name = "col3";
            col.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;


            dataGridView1.Columns.Add(col);
            dataGridView1.Columns.Add(co2);
            dataGridView1.Columns.Add(co3);

            


        }


    }
}